<?php

	// +----------------------------------------------------------------------
	// | APP设备
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\model\app;

	use app\model\file\Image;
    use think\model\concern\SoftDelete;

    class Modular extends Common
	{

        use SoftDelete;
		protected $name = 'app_modular';

		public function image()
		{
			return $this->belongsTo(Image::class)->field('id,name,save_name,driver,url');
		}

		public function cover()
		{
			return $this->belongsTo(Image::class,'cover_id')->field('id,name,save_name,driver,url');
		}

		/**
		 * 新增修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
		}
/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeWrite($data)
		{
			$data['ip'] = request()->ip();
		}

	}
